package com.whu.helpluojia.controller;

import com.whu.helpluojia.domain.User;
import com.whu.helpluojia.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/help")
public class HelpController {
    @Autowired
    UserService userService;
    @GetMapping("/resort")
    public void resort(Long id,Double x,Double y,String description){
        //求助人位置
        double temp1 = x * x + y * y;
        User[] users = userService.selectAll();
        List<User> userList = new ArrayList<>();
        for(User user : users){
            double lat = user.getLat();
            double lon = user.getLon();
            double temp2 = lat * lat + lon * lon;
            if(Math.abs(temp2 - temp1) < 500 * 500){
                userList.add(user);
            }
        }
        //向userList中的用户推送消息

    }

}
